package com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.bo;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.tjsinfo.tjsoa.Dao.IQbcDao;
import com.tjsinfo.tjsoa.documentationflow.dangweifawen.dao.ITDangweifawendengjibuDAO;
import com.tjsinfo.tjsoa.documentationflow.dangweifawen.vo.TDangweifawendengjibu;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.dao.ITXingzhengfawendengjibuDAO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.TXingzhengfawendengjibu;

public class TXingzhengfawendengjibuBO implements ITXingzhengfawendengjibuBO{
	private ITXingzhengfawendengjibuDAO xingzhengfawendengjibuDAO;
	private IQbcDao qbcDao;
	
	public IQbcDao getQbcDao() {
		return qbcDao;
	}

	public void setQbcDao(IQbcDao qbcDao) {
		this.qbcDao = qbcDao;
	}



	public ITXingzhengfawendengjibuDAO getXingzhengfawendengjibuDAO() {
		return xingzhengfawendengjibuDAO;
	}

	public void setXingzhengfawendengjibuDAO(
			ITXingzhengfawendengjibuDAO xingzhengfawendengjibuDAO) {
		this.xingzhengfawendengjibuDAO = xingzhengfawendengjibuDAO;
	}

	public Boolean addTxingzhengfawendangjibu(
			TXingzhengfawendengjibu xingzhengfawendengjibu) {
		// TODO Auto-generated method stub
		try {
			xingzhengfawendengjibuDAO.save(xingzhengfawendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	public List<TXingzhengfawendengjibu> selectAll() {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TXingzhengfawendengjibu.class);
		return qbcDao.getCriteria(criteria);
	
	}

	public TXingzhengfawendengjibu selectByDocId(String docid) {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TXingzhengfawendengjibu.class);
		criteria.add(Restrictions.eq("docid", docid));
		List<TXingzhengfawendengjibu> list = qbcDao.getCriteria(criteria);
		if (list.size() > 0) {
			TXingzhengfawendengjibu xingzhengfawendengjibu = list.get(0);
			return xingzhengfawendengjibu;
		}
		return null;
	}
	
	public Boolean updateTxingzhengdengjibu(TXingzhengfawendengjibu xingzhengfawendengjibu){
		try {
			xingzhengfawendengjibuDAO.merge(xingzhengfawendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
	
}
